<!DOCTYPE html>
<html lang="zh-Hans">
<head>
    @import "mate.html"
    <title>我要办税</title>
    <link rel="stylesheet" href="../assets/weui/lib/weui.min.css">
    <link rel="stylesheet" href="../assets/weui/css/jquery-weui.min.css">
    <link rel="stylesheet" href="../css/style.min.css">
</head>
<body>
<div class="padding-bottom">
    <div class="swiper-container" data-space-between='10' data-pagination='.swiper-pagination' data-autoplay="1000">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <img src="../images/banner.png" alt="">
            </div>
        </div>
    </div>
    <form id="cert-form" action="">
        <div class="weui-cells weui-cells_form tax-form">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">起始日期</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" id="start-time" type="text" placeholder="请选择" readonly>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">截止日期</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" id="end-time" type="text" placeholder="请选择" readonly>
                </div>
            </div>
        </div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <div class="weui-uploader">
                        <div class="weui-uploader__hd">
                            <p class="weui-uploader__title">图片上传</p>
                            <!--<div class="weui-uploader__info">0/2</div>-->
                        </div>
                        <div class="weui-uploader__bd">
                            <ul class="weui-uploader__files" id="uploaderFiles">

                                <!--<li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(./images/pic_160.png)">
                                    <div class="weui-uploader__file-content">
                                        <i class="weui-icon-warn"></i>
                                    </div>
                                </li>
                                <li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(./images/pic_160.png)">
                                    <div class="weui-uploader__file-content">50%</div>
                                </li>-->
                            </ul>
                            <div class="weui-uploader__input-box">
                                <label id="uploaderInput" class="weui-uploader__input"></label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="btn-upload">
            <button id="btn-upload" type="button" class="weui-btn btn-default">上传图片</button>
        </div>
        <!--<div class="type-title thorough-title"><span>残疾、孤老、烈属个人所得税</span></div>

        <div class="weui-cells weui-cells_form tax-form">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">减免期限</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" id="free-time" type="text" placeholder="请选择" readonly>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">金额</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入金额">
                </div>
            </div>
        </div>

        <div class="com-btn">
            <button id="button" type="button" class="weui-btn btn-default">提交申报</button>
        </div>-->

    </form>

    <!--<div style="font-size: 16px;text-align: center;line-height: 3;">
        <P>暂无可办理的优惠信息</P>
    </div>-->

</div>

@import "footer.html"
<script src="../assets/weui/js/city-picker.min.js" charset="utf-8"></script>
<script src="../assets/nice/jquery.validator.min.js"></script>
<!--<script src="../assets/layui/layui.js"></script>
<script src='../assets/lrz/lrz.bundle.js'></script>-->
<script src='../assets/webuploader/webuploader.html5only.js'></script>
<script>
  $(function () {
    var ind=0;
    $("#start-time").calendar({
//      multiple:true
      onChange:function (p,val) {
        ind++;
        var newVal=val[0].split('-'),minDate;
        minDate=newVal[0]+'-'+newVal[1]+'-'+newVal[2];
//        console.log(minDate);
        if(ind===1 && $("#end-time").val().trim()===''){
          $("#end-time").calendar({minDate:minDate});
        }else {
          $("#end-time").val('').calendar("destroy").calendar({minDate:minDate});
        }
      }
    });



      var uploader = WebUploader.create({
        auto: false,
        fileVal: 'uploadImg', //input的name字段
        compress: {
          width: 400,
//          height: 500,
          quality: 90,
          // 是否允许放大，如果想要生成小图的时候不失真，此选项应该设置为false.
          allowMagnify: false,
          // 是否允许裁剪。
          crop: false,
          // 是否保留头部meta信息。
          preserveHeaders: true,
          // 如果发现压缩后文件大小比原来还大，则使用原来图片
          // 此属性可能会影响图片自动纠正功能
          noCompressIfLarger: false,
          // 单位字节，如果图片大小小于此值，不会采用压缩。
          compressSize: 0
        },
        server: '../uploadImg/khgl/sysFiles/uploadFileForEditor2.shtml?name=',
        pick: '#uploaderInput',
//        duplicate :true,
        accept: {
          title: 'Images',
          extensions: 'gif,jpg,jpeg,bmp,png',
          mimeTypes: 'image/*'
        }
      });

      // 当有文件添加进来的时候
      uploader.on('fileQueued', function (file, data) {
        var $li=$('<li class="weui-uploader__file" id="' + file.id + '"><img class="new-img" src="" alt=""></li>');
        $('#uploaderFiles').append($li);
        var $img=$li.find('.new-img');
        uploader.makeThumb( file, function( error, src ) {
          if ( error ) {
            $img.replaceWith('<span>不能预览</span>');
            return;
          }
          $img.attr( 'src', src );
        }, 75, 75 );
      });

    // 文件前传参
    uploader.on('uploadBeforeSend', function (obj, data,hander) {
//      console.log(obj,data,hander);
      data.userinfo={
        name:'123',
        psw:'456'
      };
    });

      // 文件上传成功
      uploader.on('uploadSuccess', function (file, data) {
        $.hideLoading();
        uploader.removeFile(file, true);
        //data是返回值
      });

      // 文件上传失败，上传出错
      uploader.on('uploadError', function (file) {
        $.hideLoading();
//        location.reload();
      });

      // 完成上传完了
      uploader.on('uploadComplete', function (file) {
//        uploader.destroy();
        uploader.reset();
        console.log(1);
      });

      $('#uploaderFiles').on('click','.new-img',function () {
        $.confirm('确定要删除此图片吗？',function () {
//          console.log(1);
          $(this).parent().remove();
          var id=$(this).parent().attr('id');
//          console.log(uploader.getFile(id));
          uploader.removeFile(uploader.getFile(id,true));
        }.bind(this))
      });

      $('#btn-upload').on('click',function () {
        if($('#start-time').val()==''){
          $.alert('请选择开始日期');
          return false;
        }else if($('#end-time').val()==''){
          $.alert('请选择结束日期');
          return false;
        }else {
          /*uploader.options.formData={
            strat:$('#start-time').val(),
            dsd:$('#end-time').val()
          };*/
        }
        if(!$('.new-img').length){
          $.alert('请上传图片');
          return false;
        }else {
          $.showLoading('正在上传');
          uploader.upload();
          console.log(uploader.getFiles());
        }
      });




  })
</script>
</body>
</html>